<?php
/**
 * Created by PhpStorm.
 * User: xunuo
 * Date: 2017/6/23
 * Time: 14:40
 */

namespace app\company\controller;

class Index extends Common
{
	public function order_count()
	{
		$number = db('order')
		->field('order_id')
		->where('order_status',2)
		->whereOr('order_status',1)
		->count();
		return ['num'=>$number];
	}

	public function order_list_num()
	{
		$num = db('order')
		->field('order_id')
		->where('order_status',2)
		->whereOr('order_status',1)
		->count();
		return ['num'=>$num];
	}

	// public function index()
	// {
	// 	$model = new \app\company\model\Sqd();
    //
	// 	$remind_day = get_value(session('company.company_id'),'company','id','remind_day','0');
	// 	if(!empty($remind_day)) {
    //
	// 		$map['o.order_status'] = 3;
    //
	// 		$map['o.update_time'] = ['elt',strtotime("-1year +{$remind_day}day")];
	// 		//到期提醒数量
	// 		$data['warning_count'] = $model->get_list($map,'','',1);
    //         //小型车
	// 		$map['o.license_type'] = 1;
	// 		$data['warning_small'] = $model->get_list($map,'','',1);
    //         //中型车
	// 		$map['o.license_type'] = 2;
	// 		$data['warning_middle'] = $model->get_list($map,'','',1);
    //         //大型车
	// 		$map['o.license_type'] = 3;
	// 		$data['warning_big'] = $model->get_list($map,'','',1);
    //         //挂车
	// 		$map['o.license_type'] = 4;
	// 		$data['warning_three'] = $model->get_list($map,'','',1);
	// 	}
    //
	// 	$order_model = new \app\company\model\CsdList();
	// 	//客户资源数量
	// 	$data['member_count'] = $order_model->get_car_number();
    //     //小型车
	// 	$x['license_type'] = 1;
	// 	$data['member_small'] = $model->get_list($x,'','',1);
    //     //中型车
	// 	$x['license_type'] = 2;
	// 	$data['member_middle'] = $model->get_list($x,'','',1);
    //     //大型车
	// 	$x['license_type'] = 3;
	// 	$data['member_big'] = $model->get_list($x,'','',1);
    //     //挂车
	// 	$x['license_type'] = 4;
	// 	$data['member_three'] = $model->get_list($x,'','',1);
    //
    //
	// 	//申请单数量
	// 	$data['sqd_count'] = $model->get_list('','','',1);
    //     //未付款
	// 	$param['o.order_status'] = 0;
	// 	$data['sqd_small'] = $model->get_list($param,'','',1);
    //     //待取车
	// 	$param['o.order_status'] = 1;
	// 	$data['sqd_middle'] = $model->get_list($param,'','',1);
    //     //待检车
	// 	$param['o.order_status'] = 2;
	// 	$data['sqd_big'] = $model->get_list($param,'','',1);
    //     //已完成
	// 	$param['o.order_status'] = 3;
	// 	$data['sqd_three'] = $model->get_list($param,'','',1);
    //
	// 	return view('',$data);
	// }
    public function index()
    {
        $data = [
            'member_count'   => '',
            'sqd_count'      => '',
            'warning_count'  => '',
            'sqd_small'      => '',
            'sqd_middle'     => '',
            'sqd_big'        => '',
            'sqd_three'      => '',
            'warning_small'  => '',
            'warning_middle' => '',
            'warning_big'    => '',
            'warning_three'  => '',
            'member_small'   => '',
            'member_middle'  => '',
            'member_big'     => '',
            'member_three'   => '',
        ];
        return view('', $data);
    }

	public function menu()
	{
		return view();
	}

    /**
     * 文件上传
     * @return \think\response\Json
     */
    public function upload()
    {
    	$file = array_values(request()->file())[0];

    	$info = $file->validate(['ext' => 'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'upload');
    	if ($info) {
    		return json([
    			'result' => 0,
    			'url'    => $info->getSaveName(),
    			]);
    	} else {
    		return json([
    			'result'  => 2,
    			'message' => $file->getError(),
    			]);
    	}
    }

    public function kindEditorUpload()
    {
    	$file = array_values(request()->file())[0];

    	$info = $file->validate(['ext' => 'jpg,png,gif,avi,mp4,swf'])->move(ROOT_PATH . 'public' . DS . 'upload');
    	if ($info) {
    		return json([
    			'error' => 0,
    			'url'   => config('image_url') . DS . $info->getSaveName(),
    			]);
    	} else {
    		return json([
    			'error'   => 1,
    			'message' => $file->getError(),
    			]);
    	}
    }
}
